package com.dianping.cat.configuration.server.transform;
import com.dianping.cat.configuration.server.entity.ConsumerConfig;
import com.dianping.cat.configuration.server.entity.Domain;
import com.dianping.cat.configuration.server.entity.HarfsConfig;
import com.dianping.cat.configuration.server.entity.HdfsConfig;
import com.dianping.cat.configuration.server.entity.LongConfig;
import com.dianping.cat.configuration.server.entity.Property;
import com.dianping.cat.configuration.server.entity.Server;
import com.dianping.cat.configuration.server.entity.ServerConfig;
import com.dianping.cat.configuration.server.entity.StorageConfig;
import java.util.ArrayList;
import java.util.List;

public class DefaultLinker implements ILinker {
  private boolean m_deferrable;

  public DefaultLinker(boolean deferrable) {
/*  18 */     this.m_deferedJobs = new ArrayList();


/*  21 */     this.m_deferrable = deferrable;
  }
  private List<Runnable> m_deferedJobs;
  public void finish() {
    for (Runnable job : this.m_deferedJobs) {
/*  26 */       job.run();
    }
  }


  public boolean onConsumer(Server parent, ConsumerConfig consumer) {
    parent.setConsumer(consumer);
/*  33 */     return true;
  }


  public boolean onDomain(final LongConfig parent, final Domain domain) {
/*  38 */     if (this.m_deferrable) {
/*  39 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  42 */               parent.addDomain(domain);
            }
          });
    } else {
/*  46 */       parent.addDomain(domain);
    }

/*  49 */     return true;
  }


  public boolean onHarfs(final StorageConfig parent, final HarfsConfig harfs) {
/*  54 */     if (this.m_deferrable) {
/*  55 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  58 */               parent.addHarfs(harfs);
            }
          });
    } else {
/*  62 */       parent.addHarfs(harfs);
    }

/*  65 */     return true;
  }


  public boolean onHdfs(final StorageConfig parent, final HdfsConfig hdfs) {
/*  70 */     if (this.m_deferrable) {
/*  71 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  74 */               parent.addHdfs(hdfs);
            }
          });
    } else {
      parent.addHdfs(hdfs);
    }

/*  81 */     return true;
  }


  public boolean onLongConfig(ConsumerConfig parent, LongConfig longConfig) {
/*  86 */     parent.setLongConfig(longConfig);
/*  87 */     return true;
  }


  public boolean onProperty(final Server parent, final Property property) {
/*  92 */     if (this.m_deferrable) {
/*  93 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  96 */               parent.addProperty(property);
            }
          });
    } else {
/* 100 */       parent.addProperty(property);
    }

/* 103 */     return true;
  }


  public boolean onProperty(final StorageConfig parent, final Property property) {
/* 108 */     if (this.m_deferrable) {
/* 109 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 112 */               parent.addProperty(property);
            }
          });
    } else {
/* 116 */       parent.addProperty(property);
    }

/* 119 */     return true;
  }


  public boolean onServer(final ServerConfig parent, final Server server) {
/* 124 */     if (this.m_deferrable) {
/* 125 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 128 */               parent.addServer(server);
            }
          });
    } else {
/* 132 */       parent.addServer(server);
    }

/* 135 */     return true;
  }


  public boolean onStorage(Server parent, StorageConfig storage) {
/* 140 */     parent.setStorage(storage);
/* 141 */     return true;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-core-3.0.0.jar!/com/dianping/cat/configuration/server/transform/DefaultLinker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */